home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / akcl / kcl.lha / attport / lc1.c < prev    next >
C/C++ Source or Header  |  1986-03-11  |  911b  |  52 lines

  1. #define    KCL_SELF        "/usr2/kcl/attport/saved_kcl"
  2. #define    SYSTEM_DIRECTORY    "/usr2/kcl/attport/"
  3.  
  4. #include <stdio.h>
  5. #include <signal.h>
  6.  
  7. #define    COMSIZ    1024
  8.  
  9. main(argc, argv)
  10. int argc;
  11. char *argv[];
  12. {
  13.     int in[2];
  14.     int out[2];
  15.     char command[COMSIZ];
  16.     char buf[4];
  17.  
  18.     if (argc != 2) {
  19.         fprintf(stderr, "Arg count.\n");
  20.         exit(1);
  21.     }
  22.     printf("Compiling %s.lsp\n", argv[1]);
  23.     fflush(stdout);
  24.     pipe(in);
  25.     pipe(out);
  26.     if (in[1] != 4 || out[0] != 5) {
  27.         fprintf(stderr, "Can't get a pipe.\n");
  28.         exit(1);
  29.     }
  30.     fflush(stdout);
  31.     if (fork() != 0) {
  32.         close(in[0]);
  33.         close(out[1]);
  34.         if (execl(KCL_SELF, KCL_SELF,
  35.               SYSTEM_DIRECTORY,
  36.               argv[1], argv[1], "U1111",
  37.               0) < 0) {
  38.             fprintf(stderr, "Can't exec KCL.\n");
  39.             exit(1);
  40.         }
  41.     }
  42.     signal(SIGINT, SIG_IGN);
  43.     close(in[1]);
  44.     close(out[0]);
  45.     for (;;) {
  46.         if (read(in[0], command, COMSIZ) <= 0)
  47.             exit(0);
  48.         buf[0] = system(command);
  49.         write(out[1], buf, 1);
  50.     }
  51. }
  52.